// const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const config = require('./webpack.base.conf');

process.env.NODE_ENV = 'production';

config.performance.maxEntrypointSize((1024 ** 2) * 5);
config.performance.maxAssetSize((1024 ** 2) * 5);

config.output
  .filename('[name].[contenthash:8].js')
  .chunkFilename('[name].[contenthash:8].js');

// config.module.rule('eslint')
//   .test(/\.(tsx?|jsx?)$/)
//   .enforce('pre')
//   .use('eslint')
//   .loader('eslint-loader')
//   .end()
//   .exclude.add(/node_modules/);

// config.plugin('fork-ts-checker-webpack-plugin')
//   .use(ForkTsCheckerWebpackPlugin);

config.optimization.minimizer('terser')
  .use(TerserPlugin, [{
    terserOptions: {
      output: {
        comments: true,
      },
    },
  }]);

config.optimization.splitChunks({
  chunks: 'all',
  name: true,
  minSize: 1024 * 30,
  maxSize: 0,
  minChunks: 1,
  maxAsyncRequests: 100,
  maxInitialRequests: 100,
  automaticNameDelimiter: '~',
  automaticNameMaxLength: 80,
});


config.mode('production');
config.devtool('#source-map');

module.exports = config;
